package com.opo5.logisticsmanagement.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.opo5.logisticsmanagement.Vo.MaterialVo;
import com.opo5.logisticsmanagement.Vo.SpareVo;
import com.opo5.logisticsmanagement.dao.PlanListDao;
import com.opo5.logisticsmanagement.dao.SparePlanDao;
import com.opo5.logisticsmanagement.domain.PlanList;
import com.opo5.logisticsmanagement.domain.SparePlan;
import com.opo5.logisticsmanagement.service.PlanListService;
import com.opo5.logisticsmanagement.service.SparePlanService;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SparePlanServiceImpl extends ServiceImpl<SparePlanDao, SparePlan> implements SparePlanService {
    @Autowired(required = false)
    private SparePlanDao sparePlanDao;
    @Override
    public IPage<SparePlan> selectPage(int currentPage, int pageSize, SparePlan sparePlan) {
        LambdaQueryWrapper<SparePlan> lqw=new LambdaQueryWrapper<>();
        lqw.eq(sparePlan.getDanum()!=null,SparePlan::getDanum,sparePlan.getDanum());
        lqw.orderByAsc(SparePlan::getId);
        lqw.eq(sparePlan.getProjectnum()!=null,SparePlan::getProjectnum,sparePlan.getProjectnum());
        lqw.like(Strings.isNotEmpty(sparePlan.getProjectname()),SparePlan::getProjectname,sparePlan.getProjectname());
        lqw.eq(sparePlan.getPlanstate()!=null,SparePlan::getPlanstate,sparePlan.getPlanstate());
        IPage<SparePlan>page=new Page<>(currentPage,pageSize);
        sparePlanDao.selectPage(page,lqw);
        return page;
    }

    @Override
    public Page<SpareVo> getPageVo(Page<SpareVo> iPage) {
        return sparePlanDao.spare(iPage);
    }
//    public Page<MaterialVo> getPageVo(Page<MaterialVo> iPage) {
//        return planListDao.getElectricity(iPage);
//    }
}
